package blackstar.performance.transform.matcher;

import java.util.ArrayList;
import java.util.List;

/**
 * @author RayWoo (ayufox@gmail.com)
 *
 */
public class OrListPointCutMatcher implements PointCutMatcher
{
	private List<PointCutMatcher> methodMatchers = new ArrayList<PointCutMatcher>();

	public void addMethodMatcher(PointCutMatcher methodMatcher)
	{
		this.methodMatchers.add(methodMatcher);
	}

	public String matchPackage(String packageName)
	{
		for (PointCutMatcher matcher : methodMatchers)
		{
			String matchPackage = matcher.matchPackage(packageName);
			if (matchPackage != null)
			{
				return matchPackage;
			}
		}
		return null;
	}

	public boolean isClassMatch(String className)
	{
		for (PointCutMatcher matcher : methodMatchers)
		{
			if (matcher.isClassMatch(className))
			{
				return true;
			}
		}
		return false;
	}

	public boolean isMethodMatch(String methodName)
	{
		for (PointCutMatcher matcher : methodMatchers)
		{
			if (matcher.isMethodMatch(methodName))
			{
				return true;
			}
		}
		return false;
	}
}
